<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="./lib/axios.min.js"></script>
</head>
<body>
<form name="myForm">
	<p>用户名：<input name="username" type="text"></p>
	<p>密码：<input name="password" type="password"></p>
	<p><button>登陆</button></p>
</form>
</body>
<script>
	const form = document.myForm;
	form.onsubmit = function(e){
		e.preventDefault();
		axios.post("/login",{
			username:this.username.value.trim(),
			password:this.password.value.trim()
		}).then(({data:{ok,msg}})=>{
			if(ok === 1){
				localStorage.setItem("username",this.username.value.trim())
				location.href="/info.html"
			}else{
				alert(msg);
			}
		})
	}
</script>
</html>